package com.xqt.service.sys;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.xqt.base.dao.BaseDao;
import com.xqt.base.entity.BaseEntity;
import com.xqt.base.page.PageInfo;
import com.xqt.base.service.BaseService;
import com.xqt.dao.sys.SysMenuBtnDao;
import com.xqt.dao.sys.SysRoleDao;
import com.xqt.entity.sys.SysMenuBtn;
import com.xqt.inters.service.sys.ISysMenuBtnService;

/**
 * Created by Administrator on 2017/3/21.
 */
public class SysMenuBtnService extends BaseService<SysMenuBtn> implements ISysMenuBtnService {

    // 菜单按钮基础Dao
    @Autowired(required = false)
    private SysMenuBtnDao sysMenuBtnDao;

    // 角色基础Dao
    @Autowired(required = false)
    private SysRoleDao sysRoleDao;

    @Override
    public void add(SysMenuBtn sysMenuBtn) throws Exception {
        preAdd(sysMenuBtn);
        sysMenuBtnDao.add(sysMenuBtn);
    }

    public void update(SysMenuBtn sysMenuBtn) throws Exception {
        preUpdate(sysMenuBtn);
        sysMenuBtnDao.updateBySelective(sysMenuBtn);
    }

    @Override
    public void updateBySelective(SysMenuBtn sysMenuBtn) throws Exception {
        preUpdate(sysMenuBtn);
        sysMenuBtnDao.updateBySelective(sysMenuBtn);
    }

    @Override
    public void delete(Object... ids) {
        if (ids == null || ids.length < 1) {
            return;
        }
        for (Object id : ids) {
            sysRoleDao.deleteRoleMenuByMenuId(id);
            sysMenuBtnDao.delete(id);
        }
    }


    @Override
    public int queryByCount(BaseEntity page) {
        return sysMenuBtnDao.queryByCount(page);
    }
    
    

    @Override
    public List<SysMenuBtn> queryByList(BaseEntity page) {
        return sysMenuBtnDao.queryByList(page);
    }

	@Override
	public BaseDao<SysMenuBtn> getDao() {
		return sysMenuBtnDao;
	}
}
